package com.ctshk.rpc.order.tour.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(value="系列团订单列表跨店DTO", description="系列团订单列表跨店DTO")
public class SeriesOrderListSpanDTO implements Serializable {

    @ApiModelProperty(value = "ID")
    private Long id;

    @ApiModelProperty(value = "订单号")
    private String orderNumber;

    @ApiModelProperty(value = "团期ID")
    private Long scheduleId;

    @ApiModelProperty(value = "联络人中文姓")
    private String contactCnSurname;

    @ApiModelProperty(value = "联络人中文名")
    private String contactCnName;

    @ApiModelProperty(value = "联络人英文姓")
    private String contactEnSurname;

    @ApiModelProperty(value = "联络人英文名")
    private String contactEnName;

    @ApiModelProperty(value = "联络人性别")
    private Integer contactGender;

    @ApiModelProperty(value = "联络电话")
    private String contactTelephones;

    @ApiModelProperty(value = "联系邮箱")
    private String contactEmail;

    @ApiModelProperty(value = "内部备注")
    private String internalRemark;

    @ApiModelProperty(value = "客户类型")
    private Integer customerType;

    @ApiModelProperty(value = "大客户ID")
    private Long bigClientId;

    @ApiModelProperty(value = "大客户名称")
    private String bigClientName;

    @ApiModelProperty(value = "总人数")
    private Integer totalPeople;

    @ApiModelProperty(value = "总金额")
    private BigDecimal totalPrice;

    @ApiModelProperty(value = "房间数")
    private Integer roomNum;

    @ApiModelProperty(value = "会员ID")
    private Long memberId;

    @ApiModelProperty(value = "会员姓名")
    private String memberName;

    @ApiModelProperty(value = "会员手机号")
    private String memberMobile;

    @ApiModelProperty(value = "会员邮箱")
    private String memberEmail;

    @ApiModelProperty(value = "会员总积分")
    private String memberScore;

    @ApiModelProperty(value = "会员等级")
    private String memberLevel;

    @ApiModelProperty(value = "下单类型")
    private Integer orderType;

    @ApiModelProperty(value = "下单状态")
    private Integer placeOrderStatus;

    @ApiModelProperty(value = "所属代理商ID")
    private Long agentId;

    @ApiModelProperty(value = "代理商名称")
    private String agentName;

    @ApiModelProperty(value = "代理人ID")
    private Long agentUserId;

    @ApiModelProperty(value = "代理人名称")
    private String agentUserName;

    @ApiModelProperty(value = "创建人")
    private Long createId;

    @ApiModelProperty(value = "创建人名称")
    private String createName;

    @ApiModelProperty(value = "创建人部门")
    private String createDept;

    @ApiModelProperty(value = "修改人")
    private Long modifiedId;

    @ApiModelProperty(value = "删除标识")
    private Integer isDeleted;

    @ApiModelProperty(value = "游客人数")
    private List<SeriesOrderPageTouristPeopleDTO> touristPeopleList;

    @ApiModelProperty(value="创建时间")
    private Date gmtCreate;

    @ApiModelProperty(value="追位留位类型（1 普通 2 留位 3 追位）")
    private Integer plusTouristType;

    @ApiModelProperty(value="是否留位")
    private Integer isKeep;

    @ApiModelProperty(value="是否追位")
    private Integer isAdd;

    @ApiModelProperty(value = "应收")
    private BigDecimal totalReceivables;

    @ApiModelProperty(value = "实收")
    private BigDecimal totalPaidIn;

    @ApiModelProperty(value = "未收")
    private BigDecimal remainingReceivables;

    @ApiModelProperty(value = "未收备注")
    private String remainingReceivablesRemark;

    @ApiModelProperty(value = "退款状态")
    private Integer refundStatus;

    @ApiModelProperty(value = "退团状态")
    private Integer quitRefundStatus;

    //团期
    @ApiModelProperty(value = "'行程id（冗余）'")
    private Long tripId;

    @ApiModelProperty(value = "'行程标题(冗余)'")
    private String tripTitle;

    @ApiModelProperty(value = "'团号(冗余)'")
    private String scheduleNumber;

    @ApiModelProperty(value = "'出发日期(冗余)'")
    private LocalDate departDate;

    @ApiModelProperty(value = "团期状态(冗余)(1:未成团 2：已成团 3：停售 4：保留 5：不成团 6：已完团)")
    private Integer scheduleStatus;

    @ApiModelProperty(value = "订单来源（1：CPM云平台，2 ：CPM代理下单，3 ：PC官网，4 ：安卓，5：IOS，6：H5）")
    private Integer orderSource;

    @ApiModelProperty(value = "收款状态 1 待付款 2 待付余款 3 已付全款")
    private Integer payStatus;

    public void setTouristPeopleList(String touristPeopleList) {
        this.touristPeopleList = new ArrayList<>();
        try {
            String[] lineArray = touristPeopleList.split("\\}\\)");
            for (String line : lineArray) {
                String[] columnArray = line.split("]\\)");
                SeriesOrderPageTouristPeopleDTO dto = new SeriesOrderPageTouristPeopleDTO();
                if (columnArray.length > 0) {
                    dto.setTouristTypeName(columnArray[0]);
                }
                if (columnArray.length > 1) {
                    dto.setPeople(Integer.valueOf(columnArray[1]));
                }
                this.touristPeopleList.add(dto);
            }
        } catch (Exception e) {
        }
    }
}
